using UnityEngine;

public class PushBlock_Pushable : MonoBehaviour
{
	public bool CanPressPreasurePlates;

	public bool CanPush = true;

	[SerializeField]
	private float MoveSpeed = 5f;

	[SerializeField]
	private PushBlock_CollisionPrediction Collision;

	[SerializeField]
	private AudioClip PushSound;

	[SerializeField]
	private BoxCollider2D collision;

	[SerializeField]
	private INT_Generic Interaction;

	private bool previousInteraction;

	private bool Moving;

	private Vector2 TargetPosition;

	private EOTDRouxlsRoom_Puzzle puzzle;

	private void Start()
	{
		puzzle = Object.FindFirstObjectByType<EOTDRouxlsRoom_Puzzle>();
	}

	private void Update()
	{
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0028: Unknown result type (might be due to invalid IL or missing references)
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		//IL_0054: Unknown result type (might be due to invalid IL or missing references)
		//IL_0055: Unknown result type (might be due to invalid IL or missing references)
		//IL_005a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0063: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_010d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0118: Unknown result type (might be due to invalid IL or missing references)
		//IL_0158: Unknown result type (might be due to invalid IL or missing references)
		//IL_0125: Unknown result type (might be due to invalid IL or missing references)
		//IL_0179: Unknown result type (might be due to invalid IL or missing references)
		//IL_017a: Unknown result type (might be due to invalid IL or missing references)
		//IL_017f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0184: Unknown result type (might be due to invalid IL or missing references)
		//IL_0166: Unknown result type (might be due to invalid IL or missing references)
		//IL_0167: Unknown result type (might be due to invalid IL or missing references)
		//IL_016c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0171: Unknown result type (might be due to invalid IL or missing references)
		//IL_0146: Unknown result type (might be due to invalid IL or missing references)
		//IL_0147: Unknown result type (might be due to invalid IL or missing references)
		//IL_014c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0151: Unknown result type (might be due to invalid IL or missing references)
		//IL_0133: Unknown result type (might be due to invalid IL or missing references)
		//IL_0134: Unknown result type (might be due to invalid IL or missing references)
		//IL_0139: Unknown result type (might be due to invalid IL or missing references)
		//IL_013e: Unknown result type (might be due to invalid IL or missing references)
		//IL_018a: Unknown result type (might be due to invalid IL or missing references)
		Vector2 val = new Vector2(((Component)PlayerManager.Instance).transform.position.x, ((Component)PlayerManager.Instance).transform.position.y);
		Vector2 val2 = default(Vector2);
		((Vector2)(ref val2))._002Ector(((Component)this).transform.position.x, ((Component)this).transform.position.y);
		Vector2 val3 = val - val2;
		((Collider2D)collision).offset = ((Vector2)(ref val3)).normalized / 4f;
		if (Interaction.Interacted != previousInteraction && CanPush)
		{
			if ((Object)(object)puzzle != (Object)null && !puzzle.hasMovedPartyMembers)
			{
				puzzle.FUCKINGMOVE();
				puzzle = null;
			}
			previousInteraction = Interaction.Interacted;
			if (!Moving && !Collision.Colliding)
			{
				Moving = true;
				PlayerManager.Instance.PlayerAudioSource.PlayOneShot(PushSound);
				if (Mathf.Abs(val3.x) > Mathf.Abs(val3.y))
				{
					if (val3.x > 0f)
					{
						TargetPosition = val2 + Vector2.left;
					}
					else
					{
						TargetPosition = val2 + Vector2.right;
					}
				}
				else if (val3.y > 0f)
				{
					TargetPosition = val2 + Vector2.down;
				}
				else
				{
					TargetPosition = val2 + Vector2.up;
				}
				MonoBehaviour.print((object)TargetPosition);
			}
		}
		if (Moving)
		{
			if (Vector2.op_Implicit(((Component)this).transform.position) != TargetPosition)
			{
				((Component)this).transform.position = Vector2.op_Implicit(Vector2.MoveTowards(Vector2.op_Implicit(((Component)this).transform.position), TargetPosition, MoveSpeed * Time.deltaTime));
			}
			else
			{
				Moving = false;
			}
		}
	}
}
